<style type="text/css">
	pre {
		font-size: 11px;
		line-height: 1;
		padding: 0;
		margin: 0;
		border: 0;
		background-color: transparent;
	}
</style>
<div class="row">
	<br/>
	<div class="col-md-12">
        <table class="table table-striped table-hover" style="margin-top: 0px;word-break:break-all; word-wrap:break-all;">
		        <colgroup>
					<col width="45px">
					<col>
					<col width="150px">
					<col width="180px">
					<col width="50px">
					<col width="70px">
					<col width="50px">
					<col width="53px">
					<col width="160px">
					<col width="122px">
				</colgroup>
                <thead>
	                <tr>
	                	<td>序号</td>
	                    <td>消费者(consumer group)</td>
	                    <td data-toggle="tooltip" title="谁持有这个消费者">归属于</td>
	                    <td>用途</td>
	                    <td data-toggle="tooltip" title="集群：所有的消费者均分消息进行消费； 广播：每个消费者会消费所有消息">模式</td>
	                    <td data-toggle="tooltip" title="消费者未消费的消息数量">堆积量</td>
	                    <td data-toggle="tooltip" title="每秒消费的消息数">TPS</td>
	                    <td data-toggle="tooltip" title="追踪状态">trace</td>
	                    <td data-toggle="tooltip" title="所有队列中的最小更新时间">更新时间</td>
	                    <td>操作</td>
	                </tr>
                </thead>
                <tbody>
	                <#if response.empty && resultExt.empty>
					     <tr>
		                    <td colspan=10 align="center">
		                    	暂无数据
		                    </td>
		                <tr>
					<#else>
						<#list response.result as consumerProgressVO>
							<tr>
								<#assign row = (pagination.result.currentPage - 1)*pagination.result.numOfPage + consumerProgressVO_index + 1> 
								<td>${row}</td>
		                    	<td><a style="cursor:pointer" data="${RequestParameters.consumer!}" title="查看消费详情" data-target="#consumeDetailModel${row}" data-toggle="modal" <#if consumerProgressVO.minLastTimestamp gt 0 && consumerProgressVO.minLastTimestamp lt long.MAX_VALUE>onclick="getQueueOwner('${consumerProgressVO.consumer.name}', '${consumerProgressVO.consumer.id}')"</#if>>${consumerProgressVO.consumer.name}</a></td>
		                    	<#if consumerProgressVO.ownerList??>
		                    		<td>
			                    		<#if consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1>
				                    		<#list consumerProgressVO.ownerList as user>
				                    			<#if user_index != 0>
									    		,
									    		</#if>
									    		<span onclick="prepareDeleteUserConsumer(${user.id},'${user.name!user.getEmailName()}',${consumerProgressVO.consumer.id})" data-toggle="tooltip" title="移除${user.name!user.getEmailName()}?" class="producer_delete pointer">${user.name!user.getEmailName()}</span>
				                    		</#list>
		                    				<span class="glyphicon glyphicon-plus-sign pointer" data-toggle="tooltip" title="授权其他用户查看${consumerProgressVO.consumer.name}?" onclick="associateUserConsumer(${consumerProgressVO.consumer.id},'${consumerProgressVO.consumer.name}')"></span>
			                    		<#else>
		                    				<#list consumerProgressVO.ownerList as user>
			                    				<#if user_index != 0>
									    		,
									    		</#if>
									    		<span>${user.name!user.getEmailName()}</span>
				                    		</#list>
			                    		</#if>  		
		                    		</td>
		                    	<#else>
		                    		<td>暂无</td>
		                    	</#if>
		                    	<td class="edit-text" <#if consumerProgressVO.consumer.info?? && consumerProgressVO.consumer.info?length gt 12>data-toggle="tooltip" title="${consumerProgressVO.consumer.info}"</#if>>
									<#if consumerProgressVO.consumer.info?? && consumerProgressVO.consumer.info?length gt 12>
										<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)><span style="cursor:pointer" onclick="showUpdateInfo(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', '${consumerProgressVO.consumer.info!}')"></#if>${consumerProgressVO.consumer.info?substring(0,12)}...<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)></span></#if>
									<#else>
										<#if consumerProgressVO.consumer.info?? && consumerProgressVO.consumer.info !=''>
											<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)><span style="cursor:pointer" data-toggle="tooltip" title="修改用途" onclick="showUpdateInfo(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', '${consumerProgressVO.consumer.info!}')"></#if>${consumerProgressVO.consumer.info}<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)></span></#if>
										<#else>
											<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)>
												<span class="glyphicon glyphicon-pencil pointer" onclick="showUpdateInfo(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', '${consumerProgressVO.consumer.info!}')" data-toggle="tooltip" title="添加用途" aria-hidden="true"></span>
				                    		</#if>
										</#if>
									</#if>
								</td>
	                    		<td>集群</td>
	                    		<td>${consumerProgressVO.diff}</td>
	                    		<td>${consumerProgressVO.consumeTpsFormat}</td>
	                    		<td>
	                    			<#if topic.traceEnabled()>
		                    			<#if (consumerProgressVO.ownerList?? && consumerProgressVO.ownerList?seq_contains(userInfo.user)) || userInfo.user.type == 1>
			                    			<#if consumerProgressVO.consumer.traceEnabled()>
			                    				<span style="cursor:pointer" class="glyphicon glyphicon-eye-open" data-toggle="tooltip" title="关闭trace?" onclick="updateConsumerTraceShow(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', 1)"></span>
			                    			<#else>
			                    				<span style="cursor:pointer" class="glyphicon glyphicon-eye-close" data-toggle="tooltip" title="开启trace?" onclick="updateConsumerTraceShow(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', 0)"></span>
			                    			</#if>
		                    			<#else>
		                    				<#if consumerProgressVO.consumer.traceEnabled()><span class="glyphicon glyphicon-eye-open"></span><#else><span class="glyphicon glyphicon-eye-close"></span></#if>
		                    			</#if>
	                    			<#else>
	                    				<span class="glyphicon glyphicon-eye-close" data-toggle="tooltip" title="topic未开启trace"></span>
	                    			</#if>
	                    		</td>
	                    		<#if consumerProgressVO.minLastTimestamp == 0>
	                    			<td>暂无</td>
	                    		<#else>
	                    			<#if consumerProgressVO.minLastTimestamp == long.MAX_VALUE>
	                    				<td>消费进度不存在</td>
	                    			<#else>
			                    		<td>${consumerProgressVO.minLastTimestamp?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}</td>
	                    			</#if>
	                    		</#if>
		                    	<td>
		                    		<#if (consumerProgressVO.ownerList?? && consumerProgressVO.ownerList?seq_contains(userInfo.user)) || userInfo.user.type == 1>
			                    		<#if consumerProgressVO.offsetMap??>
				                    		<span title="跳过堆积的消息，直接消费至最新的消息" class="glyphicon glyphicon-fast-forward pointer" data-target="#skipAccumulationModel${row}" data-toggle="modal"></span>
				                    		<span title="消费过去一段时间至现在的消息" class="glyphicon glyphicon-backward pointer" data-target="#resetOffSetModel${row}" data-toggle="modal"></span>
				                    		<#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.pause?? && consumerProgressVO.consumerConfig.pause>
				                    			<span title="恢复消费" class="glyphicon glyphicon-play pointer" onclick="showPauseConsumeConfigModel(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', false<#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.pauseClientId??>,'${consumerProgressVO.consumerConfig.pauseClientId}'</#if>)" data-toggle="modal"></span>
				                    		<#else>
				                    			<span title="暂停消费【客户端需要升级至最新版本】" class="glyphicon glyphicon-pause pointer" onclick="showPauseConsumeConfigModel(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', true<#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.pauseClientId??>,'${consumerProgressVO.consumerConfig.pauseClientId}'</#if>)" data-toggle="modal"></span>
				                    		</#if>
				                    		<#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.enableRateLimit?? && consumerProgressVO.consumerConfig.enableRateLimit>
			                    				<img title="解除消费限速" width="22" height="24" style="display:inline-block;" src="${request.contextPath}/img/rateLimiter2.png" class="pointer" onclick="showLimitConsumeConfigModel(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', true, <#if consumerProgressVO.consumerConfig.permitsPerSecond??>${consumerProgressVO.consumerConfig.permitsPerSecond}<#else>${limitConsumeTps}</#if>)" data-toggle="modal"></img>
				                    		<#else>
				                    			<img title="限制消费速率【客户端需要升级至最新版本】" width="22" height="24" style="display:inline-block;" src="${request.contextPath}/img/rateLimiter.png" class="pointer" onclick="showLimitConsumeConfigModel(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', false, <#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.permitsPerSecond??>${consumerProgressVO.consumerConfig.permitsPerSecond}<#else>${limitConsumeTps}</#if>)" data-toggle="modal"></img>
				                    		</#if>
			                    		</#if>
			                    		<button type="button" class="btn btn-xs btn-warning" data-target="#deleteConsumerModel${row}" title="删除${consumerProgressVO.consumer.name}" data-toggle="modal"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
		                    		</#if>
		                    		<#if consumerProgressVO.offsetMap??>
		                    		<!-- 详情 -->
		                    		<div id="consumeDetailModel${row}" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog" style="width:700px">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>${consumerProgressVO.consumer.name}</b> 消费详情</h4>
												</div>
												<#if consumerProgressVO.dlqTopic?? && consumerProgressVO.dlqOffsetMap??>
													<table class="table table-striped table-hover" style="margin-top: 0px">
														<thead>
															<tr>
																<td class="warning" colspan=7>死消息Topic：<b style="color:red" data-toggle="tooltip" 
																title="消费失败达到最大重试次数(16)后，将会进入此topic，不再重试">${consumerProgressVO.dlqTopic}</b>
																	&nbsp;&nbsp;&nbsp;<span title="搜索死消息" class="glyphicon glyphicon-search" style="cursor:pointer;" 
																	onclick="initOffsetMsgModal('dlq', ${row}, '${consumerProgressVO.dlqTopic}','${consumerProgressVO.dlqMaxOffset?c}')" data-target="#msgSearchModal" data-toggle="modal"></span>
																</td>
															</tr>
															<tr>
																<td>broker</td>
																<td>队列</td>
																<td>最小偏移量</td>
																<td>最大偏移量</td>
																<td>消息量</td>
																<td>更新时间</td>
															</tr>
														</thead>
														<tbody>
															<#list consumerProgressVO.dlqOffsetMap as k, v>
																<tr>
																	<td>${k.brokerName}</td>
																	<td>${k.queueId}</td>
																	<td>
																		${v.minOffset?string(",###")}
																	</td>
																	<td>
																		${v.maxOffset?string(",###")}
																	</td>
																	<td>
																		${v.maxOffset - v.minOffset}
																	</td>
																	<#if v.lastUpdateTimestamp <= 0>
										                    			<td data-toggle='tooltip' title="可能消息被删了">暂无</td>
										                    		<#else>
																		<td>
																			${v.lastUpdateTimestamp?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}
																		</td>
																	</#if>
																</tr>
															</#list>
														</tbody>
													</table>
												</#if>
												<#if consumerProgressVO.retryTopic?? && consumerProgressVO.retryOffsetMap??>
													<table class="table table-striped table-hover" style="margin-top: 0px">
														<thead>
															<tr>
																<td class="warning" colspan=7>重试Topic：<b style="color:red" data-toggle="tooltip" 
																title="消费失败的消息，会重新发回到此topic，以便重试消费">${consumerProgressVO.retryTopic}</b>
																&nbsp;&nbsp;&nbsp;<span title="搜索重试消息" class="glyphicon glyphicon-search" style="cursor:pointer;" 
																onclick="initOffsetMsgModal('retry', ${row}, '${consumerProgressVO.retryTopic}','${consumerProgressVO.retryMaxOffset?c}')" data-target="#msgSearchModal" data-toggle="modal"></span>
																&nbsp;&nbsp;&nbsp;<span title="跳过重试消息" class="glyphicon glyphicon-fast-forward" style="cursor:pointer;" 
																onclick="showResetRetryMessageOffsetModel(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}')" data-toggle="modal"></span>
																</td>
															</tr>
															<tr>
																<td>客户端</td>
																<td>broker</td>
																<td>队列</td>
																<td>broker偏移量</td>
																<td>消费者偏移量</td>
																<td>堆积量</td>
																<td>消费到</td>
															</tr>
														</thead>
														<tbody>
															<#list consumerProgressVO.retryOffsetMap as k, v>
																<tr>
																	<td id="1_${consumerProgressVO.consumer.id}_${k.brokerName}_${k.queueId}"></td>
																	<td>${k.brokerName}</td>
																	<td>${k.queueId}</td>
																	<td>
																		${v.brokerOffset?string(",###")}
																	</td>
																	<td>
																		${v.consumerOffset?string(",###")}
																	</td>
																	<td>
																		${v.brokerOffset - v.consumerOffset}
																	</td>
																	<#if v.lastTimestamp <= 0>
										                    			<td data-toggle='tooltip' title="可能消息被删了">暂无</td>
										                    		<#else>
																		<td>
																			${v.lastTimestamp?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}
																		</td>
																	</#if>
																</tr>
															</#list>
														</tbody>
													</table>
												</#if>
												<table class="table table-striped table-hover" style="margin-top: 0px">
													<thead>
														<tr>
															<td class="warning" colspan=7>Topic：<b>${consumerProgressVO.topic}</td>
														</tr>
														<tr>
															<td>客户端</td>
															<td>broker</td>
															<td>队列</td>
															<td>broker偏移量</td>
															<td>消费者偏移量</td>
															<td>堆积量</td>
															<td>消费到</td>
														</tr>
													</thead>
													<tbody>
														<#list consumerProgressVO.offsetMap as k, v>
															<tr>
																<td id="0_${consumerProgressVO.consumer.id}_${k.brokerName}_${k.queueId}"></td>
																<td>${k.brokerName}</td>
																<td>${k.queueId}</td>
																<td>
																	${v.brokerOffset?string(",###")}
																</td>
																<td>
																	${v.consumerOffset?string(",###")}
																</td>
																<td>
																	${v.brokerOffset - v.consumerOffset}
																</td>
																<#if v.lastTimestamp <= 0>
									                    			<td data-toggle='tooltip' title="可能消息被删了">暂无</td>
									                    		<#else>
																	<td>
																		${v.lastTimestamp?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}
																	</td>
																</#if>
															</tr>
														</#list>
													</tbody>
												</table>
											</div>
										</div>
									</div> <!-- 详情结束 -->
									<!-- 跳过堆积 -->
									<div id="skipAccumulationModel${row}" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>确定跳过堆积的消息吗?</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="skipAccumulationBtn${row}" class="btn btn-primary" onclick="skipAccumulation(${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'skipAccumulationBtn${row}')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div><!-- 跳过堆积结束 -->
									<!-- 消息回溯-->
									<div id="resetOffSetModel${row}" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>消息回溯</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 回溯到: </label>
																		<div class="col-md-5">
																			<input type="text" id="resetOffsetDate${row}" name="resetOffsetDate" class="Wdate form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d',minDate:'%y-%M-{%d-5}'})" style="width:100%;height:34px;cursor:pointer;" readonly="readonly">
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="resetOffsetBtn${row}" class="btn btn-primary" onclick="resetOffset(${row},${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'resetOffsetBtn${row}')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div><!-- 消息回溯-->
									</#if>
									<!-- 删除consumer -->
									<div id="deleteConsumerModel${row}" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>确定删除消费者吗?</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="deleteConsumerBtn${row}" class="btn btn-primary" onclick="deleteConsumer(${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'deleteConsumerBtn${row}')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div>
									<!-- 删除consumer-->
		                    	</td>
		                   	</tr>
						</#list>
						<!-- 广播模式 -->
						<#list resultExt.result as consumerProgressVO>
							<tr>
								<#assign row = (pagination.result.currentPage - 1)*pagination.result.numOfPage + consumerProgressVO_index + 1 + response.result?size> 
								<td>${row}</td>
		                    	<td><a style="cursor:pointer" data="${RequestParameters.consumer!}" title="查看消费详情" data-target="#consumeDetailModel${row}b" data-toggle="modal">${consumerProgressVO.consumer.name}</a></td>
		                    	<#if consumerProgressVO.ownerList??>
			                    	<td>
			                    		<#if consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1>
				                    		<#list consumerProgressVO.ownerList as user>
				                    			<#if user_index != 0>
									    		,
									    		</#if>
									    		<span onclick="prepareDeleteUserConsumer(${user.id},'${user.name!user.getEmailName()}',${consumerProgressVO.consumer.id})" data-toggle="tooltip" title="移除${user.name!user.getEmailName()}?" class="producer_delete pointer">${user.name!user.getEmailName()}</span>
				                    		</#list>
		                    				<span class="glyphicon glyphicon-plus-sign pointer" data-toggle="tooltip" title="授权其他用户查看${consumerProgressVO.consumer.name}?" onclick="associateUserConsumer(${consumerProgressVO.consumer.id},'${consumerProgressVO.consumer.name}')"></span>
		                    			<#else>
		                    				<#list consumerProgressVO.ownerList as user>
		                    					<#if user_index != 0>
									    		,
									    		</#if>
									    		<span>${user.name!user.getEmailName()}</span>
				                    		</#list>
		                    			</#if>    		
			                    	</td>
		                    	<#else>
		                    		<td>暂无</td>
		                    	</#if>
								<td class="edit-text" <#if consumerProgressVO.consumer.info?? && consumerProgressVO.consumer.info?length gt 12>data-toggle="tooltip" title="${consumerProgressVO.consumer.info}"</#if>>
									<#if consumerProgressVO.consumer.info?? && consumerProgressVO.consumer.info?length gt 12>
										<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)><span style="cursor:pointer" onclick="showUpdateInfo(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', '${consumerProgressVO.consumer.info!}')"></#if>${consumerProgressVO.consumer.info?substring(0,12)}...<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)></span></#if>
									<#else>
										<#if consumerProgressVO.consumer.info?? && consumerProgressVO.consumer.info !=''>
											<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)><span style="cursor:pointer" data-toggle="tooltip" title="修改用途" onclick="showUpdateInfo(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', '${consumerProgressVO.consumer.info!}')"></#if>${consumerProgressVO.consumer.info}<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)></span></#if>
										<#else>
											<#if consumerProgressVO.ownerList?? && (consumerProgressVO.ownerList?seq_contains(userInfo.user) || userInfo.user.type == 1)>
				                    			<span class="glyphicon glyphicon-pencil pointer" onclick="showUpdateInfo(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', '${consumerProgressVO.consumer.info!}')" data-toggle="tooltip" title="添加用途" aria-hidden="true"></span>
				                    		</#if>
										</#if>
									</#if>
								</td>
	                    		<td>广播</td>
	                    		<td>${consumerProgressVO.diff}</td>
	                    		<td>${consumerProgressVO.consumeTpsFormat}</td>
	                    		<td><span class="glyphicon glyphicon-eye-close" data-toggle="tooltip" title="广播模式不支持trace"></span></td>
	                    		<#if consumerProgressVO.minLastTimestamp == 0>
	                    			<td>暂无</td>
	                    		<#else>
	                    			<#if consumerProgressVO.minLastTimestamp == long.MAX_VALUE>
	                    				<td>消费进度不存在</td>
	                    			<#else>
			                    		<td>${consumerProgressVO.minLastTimestamp?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}</td>
	                    			</#if>
	                    		</#if>
		                    	<td>
		                    		<#if (consumerProgressVO.ownerList?? && consumerProgressVO.ownerList?seq_contains(userInfo.user)) || userInfo.user.type == 1>
			                    		<#if consumerProgressVO.offsetMap??>
				                    		<span title="跳过堆积的消息，直接消费至最新的消息" class="glyphicon glyphicon-fast-forward pointer" data-target="#skipAccumulationModel${row}b" data-toggle="modal"></span>
				                    		<span title="消费过去一段时间至现在的消息" class="glyphicon glyphicon-backward pointer" data-target="#resetOffSetModel${row}b" data-toggle="modal"></span>
			                    			<#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.pause?? && consumerProgressVO.consumerConfig.pause>
						               			<span title="恢复消费" class="glyphicon glyphicon-play pointer" onclick="showPauseConsumeConfigModel(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', false<#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.pauseClientId??>,'${consumerProgressVO.consumerConfig.pauseClientId}'</#if>)" data-toggle="modal"></span>
						               		<#else>
						               			<span title="暂停消费" class="glyphicon glyphicon-pause pointer" onclick="showPauseConsumeConfigModel(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', true<#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.pauseClientId??>,'${consumerProgressVO.consumerConfig.pauseClientId}'</#if>)" data-toggle="modal"></span>
						               		</#if>
						               		<#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.enableRateLimit?? && consumerProgressVO.consumerConfig.enableRateLimit>
						           				<img title="解除消费限速" width="22" height="24" style="display:inline-block;" src="${request.contextPath}/img/rateLimiter2.png" class="pointer" onclick="showLimitConsumeConfigModel(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', true, <#if consumerProgressVO.consumerConfig.permitsPerSecond??>${consumerProgressVO.consumerConfig.permitsPerSecond}<#else>${limitConsumeTps}</#if>)" data-toggle="modal"></img>
						               		<#else>
						               			<img title="限制消费速率" width="22" height="24" style="display:inline-block;" src="${request.contextPath}/img/rateLimiter.png" class="pointer" onclick="showLimitConsumeConfigModel(${consumerProgressVO.consumer.id}, '${consumerProgressVO.consumer.name}', false, <#if consumerProgressVO.consumerConfig?? && consumerProgressVO.consumerConfig.permitsPerSecond??>${consumerProgressVO.consumerConfig.permitsPerSecond}<#else>${limitConsumeTps}</#if>)" data-toggle="modal"></img>
						               		</#if> 
			                    		</#if>
			                    		<button type="button" class="btn btn-xs btn-warning" data-target="#deleteConsumerModel${row}b" title="删除${consumerProgressVO.consumer.name}" data-toggle="modal"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
		                    		</#if>
		                    		<#if consumerProgressVO.offsetMap??>
		                    		<!-- 详情 -->
		                    		<div id="consumeDetailModel${row}b" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog" style="width:700px">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>${consumerProgressVO.consumer.name}</b> 消费详情</h4>
												</div>
												<table class="table table-striped table-hover" style="margin-top: 0px">
													<thead>
														<tr>
															<td>clientId</td>
															<td>broker</td>
															<td>队列</td>
															<td>broker偏移量</td>
															<td>消费者偏移量</td>
															<td>堆积量</td>
														</tr>
													</thead>
													<tbody>
														<#list consumerProgressVO.consumeStatsList as consumeStats>
															<tr>
																<td rowspan=${consumeStats.offsetTable?size+1}>${consumeStats.clientId}</td>
															</tr>
															<#list consumeStats.offsetTable as mq,offset>
															<tr>
																<td>${mq.brokerName}</td>
																<td>${mq.queueId}</td>
																<td>
																	${offset.brokerOffset?string(",###")}
																</td>
																<td>
																	${offset.consumerOffset?string(",###")}
																</td>
																<td>
																	${offset.brokerOffset - offset.consumerOffset}
																</td>
															</tr>
															</#list>
														</#list>
													</tbody>
												</table>
											</div>
										</div>
									</div> <!-- 详情结束 -->
									<!-- 跳过堆积 -->
									<div id="skipAccumulationModel${row}b" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>确定跳过堆积的消息吗?</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="skipAccumulationBtn${row}b" class="btn btn-primary" onclick="skipAccumulation(${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'skipAccumulationBtn${row}b')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div><!-- 跳过堆积结束 -->
									<!-- 消息回溯-->
									<div id="resetOffSetModel${row}b" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>消息回溯</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 回溯到: </label>
																		<div class="col-md-5">
																			<input type="text" id="resetOffsetDate${row}b" name="resetOffsetDate" class="Wdate form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d',minDate:'%y-%M-{%d-5}'})" style="width:100%;height:34px;cursor:pointer;" readonly="readonly">
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="resetOffsetBtn${row}b" class="btn btn-primary" onclick="resetOffset('${row}b',${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'resetOffsetBtn${row}b')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div><!-- 消息回溯-->
									</#if>
									<!-- 删除consumer -->
									<div id="deleteConsumerModel${row}b" class="modal fade" tabindex="-1" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
													<h4 class="modal-title"><b>确定删除消费者吗?</h4>
												</div>
												<form class="form-horizontal form-bordered form-row-stripped">
													<div class="modal-body">
														<div class="row">
															<div class="col-md-12">
																<div class="form-body">
																	<div class="form-group">
																		<label class="control-label col-md-3"> Topic: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.topic}" class="form-control" />
																		</div>
																	</div>
																	<div class="form-group">
																		<label class="control-label col-md-3"> 消费者: </label>
																		<div class="col-md-5">
																			<input type="text" readonly="readonly" value="${consumerProgressVO.consumer.name}" class="form-control" />
																		</div>
																	</div>
																</div>
															</div>
														</div>
													</div>
													<div  class="modal-footer">
														<button type="button" data-dismiss="modal" class="btn" >取消</button>
														<button type="button" id="deleteConsumerBtn${row}b" class="btn btn-primary" onclick="deleteConsumer(${consumerProgressVO.consumer.tid},${consumerProgressVO.consumer.id},'deleteConsumerBtn${row}b')">确定</button>
													</div>
												</form>
											</div>
										</div>
									</div>
									<!-- 删除consumer-->
		                    	</td>
		                   	</tr>
						</#list>
						<#if pagination.OK && pagination.result.totalPages gt 1>
		                	<tr><td colspan=10 align="center"><ul id="pagination" style="margin:0px;" data-url="${request.contextPath}/user/topic/${RequestParameters.tid}/detail?tab=consume"></ul></td></tr>
						</#if>
					</#if>
                </tbody>
           </table>
    </div>
</div>
<!-- 提示弹窗 -->
<div class="modal fade" id="deleteUserConsumerModal" aria-hidden="true">  
  <div class="modal-dialog">  
    <div class="modal-content message_align">  
      <div class="modal-header">  
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>  
        <h4 class="modal-title">确定要移除用户吗？</h4>  
      </div>  
		<form class="form-horizontal form-bordered form-row-stripped">
			<div class="modal-body">
				<div class="row">
					<!-- 控件开始 -->
					<div class="col-md-12">
						<!-- form-body开始 -->
						<div class="form-body">
							<div class="form-group">
								<label class="control-label col-md-3"> 用户: </label>
								<div class="col-md-5">
									<input type="text" id="user_name" class="form-control" readonly="readonly"/>
									<input type="hidden" id="currentUid"/>
									<input type="hidden" id="currentCid"/>
								</div>
							</div>						
						</div>
						<!-- form-body 结束 -->
					</div>
					<div id="info"></div>
					<!-- 控件结束 -->
				</div>
			</div>
			
			<div class="modal-footer">
				<button type="button" data-dismiss="modal" class="btn" >取消</button>
				<button type="button" id="deleteUserConsumerBtn" onclick="deleteUserConsumer()" class="btn btn-primary">确定</button>
			</div>
		
		</form>
    </div>
  </div>
</div>
<div id="addUserConsumerModal" class="modal fade" tabindex="-1" data-width="400">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title">授权其他用户</h4>
			</div>
			<form class="form-horizontal form-bordered form-row-stripped" id="addUserProducerModalForm">
				<div class="modal-body">
					<div class="row">
						<div class="col-md-12">
							<div class="form-body">
								<div class="form-group">
									<label class="control-label col-md-3"> Topic: </label>
									<div class="col-md-5">
										<input type="text" id="topicName" readonly="readonly" class="form-control"/>
									</div>
								</div>
								<div id="consumerGroup" class="form-group">
									<label class="control-label col-md-3"> 消费者: </label>
									<div class="col-md-5">
										<input type="text" id="consumerGroupName" readonly="readonly" class="form-control" />
										<input type="hidden" id="consumerGroupID"/>
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-3"> 选择用户: </label>
							        <div class="col-md-5">
			    						<select id="user_search_select" class="selectpicker" title="请选择" data-live-search-placeholder="搜索" data-live-search="true"></select> 	  			
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" data-dismiss="modal" class="btn" >取消</button>
					<button type="button" class="btn btn-primary" id="associateUserConsumerBtn" onclick="addUserCounsumerRelationship()">确定</button>
				</div>
			</form>
		</div>
	</div>
</div>
<!-- 准备搜索部分 -->
<div class="row">
<div class="col-md-12">
	<div class="border-top"></div>
	<div style="float:left;margin:10px 5px;"><h5><b>${topic.name}</b> 消费流量图</h5></div>
	<div id="consume_search" style="float:right;margin:10px 0px;"></div>
</div>
</div>
<!-- 准备曲线图 -->
<div id="consume_lineChart"><center>暂无数据</center></div>

<!-- 偏移量消息搜索 -->
<div id="msgSearchModal" class="modal fade" tabindex="-1">
	<div class="modal-dialog" style="width:1050px">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" onclick="hideMsgSearchModal()" aria-hidden="true">&times;</button>
				<h4 class="modal-title">消息查询</h4>
			</div>
			<div class="modal-body">
				<div style="float:left;margin:0px 5px;">
					<form class="form-inline">
						<div class="form-group" id="searchConditionForm">
							<label for="type">查询方式: </label>
						    <select id="searchCondition" class="selectpicker form-control">
								<option data-title="按照key查询消息，最多可查时间段内的brokerSize*64条" value="key">key</option>
								<option data-title="按照偏移量查询消息,最多检索5000条" value="offset">偏移量</option>
								<option data-title="按照时间段查询消息,最多检索5000条" value="time">时间段</option>
							</select>
						</div>
					</form>
				</div>
				<div style="float:right;margin:0px 0px 10px 0px;">
					<form class="form-inline" id="msgSearchForm">
						<div>
							<!-- 偏移量查询 -->
							<div class="form-group offset" style="display:none;">
								<label for="offsetStart"> 起始偏移量: </label>
								<input id="offsetStart" name="offsetStart" type="text" class="form-control" style="width:120px;" placeholder="broker最小偏移量">
							</div>
							<div class="form-group offset" style="display:none;">
					  			<label for="offsetEnd"> 结束偏移量: </label>
								<input id="offsetEnd" name="offsetEnd" type="text" class="form-control" style="width:120px;" placeholder="broker最大偏移量">
							</div>
							<div class="form-group offset" style="display:none;">
					    	    <input type="text" class="form-control" id="toKey" name="toKey" style="width:150px;" placeholder="关键字">
					  	    </div>
					  	    
		  	    			<!-- 时间段查询 -->
							<div class="form-group time" style="display:none;">
								<label for="timeStartTimePicker"> 开始时间: </label>
								<input id="timeStartTimePicker" type="text" class="Wdate form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d',minDate:'%y-%M-{%d-${cluster.fileReservedDays}}',onpicked:function(){timeChange('timeStartTime')}})" style="width:180px;height:34px;cursor:pointer;" readonly="readonly"
					  								value="${(.now?long-300000)?number_to_datetime?string("yyyy-MM-dd HH:mm:ss")}">
					  			<input type="hidden" name="startTime" id="timeStartTime" value="${.now?long-300000}">
					  			<label for="timeEndTimePicker"> 结束时间: </label>
								<input id="timeEndTimePicker" type="text" class="Wdate form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d',minDate:'%y-%M-{%d-${cluster.fileReservedDays}}',onpicked:function(){timeChange('timeEndTime')}})" style="width:180px;height:34px;cursor:pointer;" readonly="readonly"
					  								value="${.now}">
					  			<input type="hidden" name="endTime" id="timeEndTime" value="${.now?long}">
							</div>
							<div class="form-group time" style="display:none;">
					    	    <input type="text" class="form-control" id="key" name="key" placeholder="关键字，支持模糊匹配">
					  	    </div>
					  	    <!-- key查询 -->
					  	    <div class="form-group key">
								<label for="keyStartTimePicker"> 开始时间: </label>
								<input id="keyStartTimePicker" type="text" class="Wdate form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d',minDate:'%y-%M-{%d-${cluster.fileReservedDays}}',onpicked:function(){timeChange('keyStartTime')}})" style="width:180px;height:34px;cursor:pointer;" readonly="readonly"
					  								value="${.now?string("yyyy-MM-dd 00:00:00")}">
					  			<input type="hidden" id="keyStartTime" name="keyStartTime">
					  			<label for="keyEndTimePicker"> 结束时间: </label>
								<input id="keyEndTimePicker" type="text" class="Wdate form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d',minDate:'%y-%M-{%d-${cluster.fileReservedDays}}',onpicked:function(){timeChange('keyEndTime')}})" style="width:180px;height:34px;cursor:pointer;" readonly="readonly"
					  								value="${.now}">
					  			<input type="hidden" name="keyEndTime" id="keyEndTime" value="${.now?long}">
							</div>
					  	    <div class="form-group key">
					    	    <input type="text" class="form-control" id="msgKey" name="msgKey" placeholder="消息key">
							</div>
			
							<input type="hidden" id="toCid" name="toCid" value="${topic.clusterId}">
		  	    			<input type="hidden" id="toTopic" name="toTopic" value="">
		  	    			<input type="hidden" id="toMessageParam" name="toMessageParam">
		  	    			<input type="hidden" id="toAppend" name="toAppend" value="false">
		  	    			
		  	    			<!-- 时间段查询 -->
							<button type="button" data-toggle='tooltip' title="按时间段查询" onclick="searchMessage(false)" class="btn btn-search time" style="display:none;"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
							<!-- key查询 -->
							<button type="button" data-toggle='tooltip' title="按key查询" onclick="searchKeyMessage()" class="btn btn-search key"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
							<!-- 偏移量查询 -->
							<button type="button" onclick="showMoreSearchCondition()" class="btn offset" data-toggle="tooltip" title="单击展开更多搜索项" style="display:none;"><span class="glyphicon glyphicon-filter" aria-hidden="true"></span></button>
							<button type="button" data-toggle='tooltip' title="按偏移量查询" onclick="searchOffsetMessage(false)" class="btn btn-search offset" style="display:none;"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
							<!-- 消息重发 -->
							<button type="button" id="resendMessageBtn" data-toggle='tooltip' title="重发消息" onclick="resendMessageTip()" class="btn"><span class="glyphicon glyphicon-send"></span></button>
						</div>
						<div class="form-group hide" id ="moreSearchCondition" style="margin-top:10px">
							<label style="margin-left:23px"> broker: </label>
							<select id="brokerNameSearchSelect" class="selectpicker" name="toBrokerName" onchange="brokerNameSelectChange(this)"></select>
							<label style="margin-left:27px"> queue: </label>
							<select id="queueSearchSelect" class="selectpicker" name="toQueue" onchange="queueSelectChange(this)">
							<option value="-1">全部</option>
							</select>
						</div>	
					</form>
				</div>
				<table id="dataTable" class="table table-striped table-hover" style="margin-top: 0px;word-break:break-all; word-wrap:break-all;">
					<colgroup>
						<col width="50px">
						<col width="110px">
						<col width="190px">
						<col width="100px">
						<col>
					</colgroup>
					<thead>
						<tr>
							<td>序号</td>
							<td>客户端</td>
							<td>发送时间</td>
							<td id="cosumeTimes">消费次数</td>
							<td>消息</td>
						</tr>
					</thead>
					<tbody>
						<tr class="no_more_data"><td colspan=5 class="text-center">暂无数据</td></tr>
					</tbody>
				</table>
				<ul class="pager" id="pager" style="display:none;">
					<li id="previous" class="previous" onclick="previous()"><a href="javascript:void(0)">&larr; 上一页</a></li>
					<li><a href="#">第<b id="pageNum"></b>页，命中数：<b id="sizeNum"></b>，检索数：<b id="searchNum"></b>，预估剩余数：<b id="leftNum"></b></a></li>
					<li id="next" class="next" onclick="next()"><a href="javascript:void(0)">下一页 &rarr;</a></li>
				</ul>
			</div>
		</div>
	</div>
</div>

<#--修改consumer描述-->
<div id="updateConsumerInfoModal" class="modal fade" tabindex="-1">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title"><b id="consumerTitle"></b>用途更新</h4>
			</div>
			<form class="form-horizontal form-bordered form-row-stripped" id="addUserProducerModalForm">
				<div class="modal-body">
					<div class="row">
						<div class="col-md-12">
							<div class="form-body">
								<div class="form-group">
									<label class="control-label col-md-2"> 用途: </label>
									<div class="col-md-9">
										<textarea id="consumerInfo" rows="5" class="form-control"></textarea>
									</div>
									<input type="hidden" id="currentConsumerID">
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" data-dismiss="modal" class="btn" >取消</button>
					<button type="button" class="btn btn-primary" id="updateConsumerInfoBtn" onclick="updateConsumerInfo()">确定</button>
				</div>
			</form>
		</div>
	</div>
</div> 

<!-- 重试消息跳过-->
<div id="resetRetryMessageOffsetModel" class="modal fade" tabindex="-1" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title"><b>跳过重试消息</h4>
			</div>
			<form class="form-horizontal form-bordered form-row-stripped">
				<div class="modal-body">
					<div class="row">
						<div class="col-md-12">
							<div class="form-body">
								<div class="form-group">
									<label class="control-label col-md-3"> 消费者: </label>
									<div class="col-md-7">
										<input type="text" id="resetRetryMessageOffsetConsumer" name="consumer" readonly="readonly" class="form-control" />
										<input type="hidden" id="resetRetryMessageOffsetConsumerId">
									</div>
								</div>
								<div class="form-group">
									<label class="control-label col-md-3"> 跳至: </label>
									<div class="col-md-7">
										<input type="text" id="resetRetryMessageOffsetDate" class="Wdate form-control" onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d',minDate:'%y-%M-%d'})" style="width:100%;height:34px;cursor:pointer;" readonly="readonly">
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div  class="modal-footer">
					<button type="button" data-dismiss="modal" class="btn" >取消</button>
					<button type="button" id="resetRetryMessageOffsetBtn" class="btn btn-primary" onclick="resetRetryOffset('resetRetryMessageOffsetBtn')">确定</button>
				</div>
			</form>
		</div>
	</div>
</div><!-- 消息回溯-->

<!-- 消息重发确认 -->
<div id="resendMsgModal" class="modal fade" tabindex="-1" data-width="400">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title">消息重发</h4>
			</div>
			<form class="form-horizontal form-bordered form-row-stripped">
				<div class="form-group">
					<label class="control-label col-md-3"> 消息序号: </label>
					<div class="col-md-7">
		        		<div class="form-control-static"><b id="dataIdx" style="word-break:break-all"></b></div>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-md-3"> 发给: </label>
					<div class="col-md-7">
						<select id="consumerSelect" class="selectpicker" title="请选择" data-live-search-placeholder="搜索" data-live-search="true"></select>
					</div>
				</div>
			</form>
			<div class="modal-footer">
				<button type="button" data-dismiss="modal" class="btn" >取消</button>
				<button type="button" class="btn btn-primary" id="resendBtn" onclick="resendMessage()">确定</button>
			</div>
		</div>
	</div>
</div>

<#--修改consumer trace-->
<div id="updateConsumerTraceModal" class="modal fade" tabindex="-1" data-width="400">
	<div class="modal-dialog" style="width:400px;">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="consumerH4"></h4>
			</div>
			<form class="form-horizontal form-bordered form-row-stripped">
				<div class="modal-body">
					<div class="row">
						<div class="col-md-12">
							<div class="form-body">
								<div class="form-group">
									<div class="col-md-4"></div>
									<div class="col-md-8">
										<div class="form-control-static">
											<span id='traceSapn'></span> trace ?
	    								</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" data-dismiss="modal" class="btn" >取消</button>
					<button type="button" class="btn btn-primary" id="updateConsumerTraceBtn" onclick="updateConsumerTrace()">确定</button>
				</div>
			</form>
		</div>
	</div>
</div> 

<!-- 暂停消费 -->
<div id="pauseConsumeConfigModel" class="modal fade" tabindex="-1" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<span class="h4"><b id="pauseConsumeTip"></b>消费</span><span class="nostyleA" data-toggle="tooltip" data-placement="bottom" title="详细释义"><a href="/wiki/userGuide/clientConsumer#pauseConsumer" target=_blank class="glyphicon glyphicon-question-sign"></a></span>
			</div>
			<div class="modal-body">
				<form class="form-horizontal form-bordered form-row-stripped" id="pauseConsumeConfigForm">
					<input type="hidden" id="pauseConsumeIdInput" name="consumerId">
					<input type="hidden" id="pauseConsumeBoolean" name="pause">
					<div class="form-body">
						<div class="form-group">
							<label class="control-label col-md-3"> 消费者: </label>
							<div class="col-md-5">
								<input type="text" readonly="readonly" id="pauseConsumeName" value="" class="form-control" />
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3"> 客户端: </label>
						<div class="col-md-5">
							<select id="pauseClientIdSelect" class="selectpicker" title="不选默认应用于所有的消费者" name="pauseClientId" data-live-search="true" multiple data-max-options="1">
							</select>
						</div>
					</div>
				</form>
			</div>
			<div  class="modal-footer">
				<button type="button" data-dismiss="modal" class="btn" >取消</button>
				<button type="button" id="pauseConsumeConfigBtn" class="btn btn-primary" onclick="pauseConsumeConfig()">确定</button>
			</div>
		</div>
	</div>
</div><!-- 暂停消费 -->

<!-- 消费限速 -->
<div id="limitConsumeConfigModel" class="modal fade" tabindex="-1" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<span class="h4">消费限速</span><span class="nostyleA" data-toggle="tooltip" data-placement="bottom" title="详细释义"><a href="/wiki/userGuide/clientConsumer#limitConsumer" target=_blank class="glyphicon glyphicon-question-sign"></a></span>
			</div>
			<div class="modal-body">
				<form class="form-horizontal form-bordered form-row-stripped" id="limitConsumeConfigForm">
					<input type="hidden" id="limitConsumeIdInput" name="consumerId">
					<div class="form-body">
						<div class="form-group">
							<label class="control-label col-md-3"> 消费者: </label>
							<div class="col-md-6">
								<input type="text" readonly="readonly" id="limitConsumeName" value="" class="form-control" />
							</div>
						</div>
					</div>
					<div class="form-body">
						<div class="form-group">
							<label class="control-label col-md-3"> 限制消费速率: </label>
							<div class="col-md-6 checkbox">
								<label data-toggle="tooltip" title="每个实例将会参照TPS进行限速">
								    <input type="radio" id="enableRateLimitRadio" name="enableRateLimit" value="true">是
								</label>
								<label data-toggle="tooltip" title="每个实例将会关闭限速">
								    <input type="radio" id="disableRateLimitRadio" name="enableRateLimit" value="false" checked>否
								</label>
							</div>
						</div>
					</div>
					<div class="form-body">
						<div class="form-group">
							<label class="control-label col-md-3" data-toggle="tooltip" title="消息流控，最小值为1"> TPS: </label>
							<div class="col-md-6">
								<input type="text" id="permitsPerSecondInput" data-toggle="tooltip" name="permitsPerSecond" value="${limitConsumeTps}" title="例如：${limitConsumeTps}代表每个实例每秒最多消费${limitConsumeTps}条消息" class="form-control" />
							</div>
						</div>
					</div>
				</form>
			</div>
			<div  class="modal-footer">
				<button type="button" data-dismiss="modal" class="btn" >取消</button>
				<button type="button" id="limitConsumeBtn" class="btn btn-primary" onclick="limitConsume()">确定</button>
			</div>
		</div>
	</div>
</div>
<#include "../inc/paginationNoNav.html">
<script>
/**
 * 限制消费速率
 */
function showLimitConsumeConfigModel(consumerId, consumer, enableRateLimit, permitsPerSecond){
	$("#limitConsumeConfigForm")[0].reset();
	if(enableRateLimit){
		$("#enableRateLimitRadio").prop("checked",true);
	} else {
		$("#disableRateLimitRadio").prop("checked",true);
	}
	if(permitsPerSecond){
		$("#permitsPerSecondInput").val(permitsPerSecond);
	}
	$("#limitConsumeIdInput").val(consumerId);
	$("#limitConsumeName").val(consumer);
	$("#limitConsumeConfigModel").modal('show');
}
/**
 * 暂停恢复消费者
 */
function showPauseConsumeConfigModel(consumerId, consumer, pause, pauseClientId){
	$("#pauseConsumeConfigBtn").attr("disabled", "disabled");
	$.get('${request.contextPath}/consumer/connection',{
		group: consumer,
		cid: ${topic.clusterId},
	},function(data){
          if(data.status == 200){
          	var content = "";
          	for(var i in data.result){
          		var ip = data.result[i];
         		content += "<option value='"+ip+"'>"+ip+"</option>";
          	}
      		$("#pauseClientIdSelect").html(content);
      		$("#pauseClientIdSelect").selectpicker('refresh');
      		$("#pauseConsumeConfigBtn").removeAttr("disabled");
      		if(pauseClientId){
	      		$('#pauseClientIdSelect').selectpicker('val', pauseClientId);
      		}
	    } else {
	    	toastr.error("数据获取失败！"+data.message);  
	    }
    }, 'json');
	if(pause){
		$("#pauseConsumeTip").html("暂停");
	} else {
		$("#pauseConsumeTip").html("恢复");
	}
	$("#pauseConsumeBoolean").val(pause);
	$("#pauseConsumeIdInput").val(consumerId);
	$("#pauseConsumeName").val(consumer);
	$("#pauseConsumeConfigModel").modal('show');
}
/**
 * 暂停消费
 */
function pauseConsumeConfig(){
	disable("pauseConsumeConfigBtn");
	$.get('${request.contextPath}/consumer/update/config',
	$("#pauseConsumeConfigForm").serialize()
	,function(data){
        if(data.status == 200){
			toastr.success(data.message);  
			modalHide(3000);
	    }else{
	    	toastr.error("操作失败！"+data.message);  
	    	enable("pauseConsumeConfigBtn");
	    }
    }, 'json');
}

/**
 * 限速
 */
function limitConsume(){
	var tps = Number($("#permitsPerSecondInput").val());
	if(tps < 1){
		alert("tps不能小于1");
		return;
	}
	if(!Number.isInteger(tps)){
		alert("tps只能为正整数");
		return;
	}
	disable("limitConsumeBtn");
	$.get('${request.contextPath}/consumer/update/config',
	$("#limitConsumeConfigForm").serialize()
	,function(data){
        if(data.status == 200){
			toastr.success(data.message);  
			modalHide(3000);
	    }else{
	    	toastr.error("操作失败！"+data.message);  
	    	enable("limitConsumeBtn");
	    }
    }, 'json');
}

function showUpdateInfo(cid, consumer, info){
	$("#currentConsumerID").val(cid);
	$("#consumerTitle").html(consumer);
	$("#consumerInfo").val(info);
	$("#updateConsumerInfoModal").modal('show');
}

function showResetRetryMessageOffsetModel(consumerId, consumer){
	$("#resetRetryMessageOffsetConsumer").val(consumer);
	$("#resetRetryMessageOffsetConsumerId").val(consumerId);
	$("#resetRetryMessageOffsetModel").modal('show');
}
/**
 * 重置重试偏移量
 */
function resetRetryOffset(btn){
	var resetOffsetTo = $("#resetRetryMessageOffsetDate").val();
	if(!resetOffsetTo){
		alert("请选择跳到的时间!");
		return;
	}
	disable(btn);
	$.get('${request.contextPath}/consumer/skip/retryOffset',{
		tid: ${RequestParameters.tid},
		consumerId: $("#resetRetryMessageOffsetConsumerId").val(),
		offset: resetOffsetTo,
		cid: $("#toCid").val()
	},function(data){
        if(data.status == 200){
			toastr.success(data.message);  
			modalHide(3000);
	    }else{
	    	toastr.error("操作失败！"+data.message);  
	    	enable(btn);
	    }
    }, 'json');
}
/**
 * 跳过堆积
 */
function skipAccumulation(tid, cid, btn){
	disable(btn);
	$.get('${request.contextPath}/consumer/resetOffset',{
		tid: tid,
		consumerId: cid,
		cid: $("#toCid").val()
	},function(data){
        if(data.status == 200){
			toastr.success(data.message);  
			modalHide(3000);
	    }else{
	    	toastr.error("操作失败！"+data.message);  
	    	enable(btn);
	    }
    }, 'json');
}
/**
 * 重置偏移量
 */
function resetOffset(idx, tid, cid, btn){
	var resetOffsetTo = $("#resetOffsetDate"+idx).val();
	if(!resetOffsetTo){
		alert("请选择回溯到的时间!");
		return;
	}
	disable(btn);
	$.get('${request.contextPath}/consumer/resetOffset',{
		tid: tid,
		consumerId: cid,
		offset: resetOffsetTo,
		cid: $("#toCid").val()
	},function(data){
        if(data.status == 200){
			toastr.success(data.message);  
			modalHide(3000);
	    }else{
	    	toastr.error("操作失败！"+data.message);  
	    	enable(btn);
	    }
    }, 'json');
}
/**
 * 删除消费者
 */
function deleteConsumer(tid, cid, btn){
	disable(btn);
	$.post('${request.contextPath}/consumer/delete',{
		tid: tid,
		consumerId: cid
	},
    function(data){
        if(data.status == 200){
			toastr.success("删除消费者申请成功");  
			modalHide(3000);
	    }else{
	    	toastr.error("操作失败！"+data.message);  
	    	enable(btn);
	    }
    }, 'json');
}

$(function(){
	$("[data-toggle='tooltip']").tooltip({container: 'body'});
	$("[data-toggle='modal']").tooltip({container: 'body'});
	 //添加删除特效
    $(".producer_delete").hover(function(){
    	$(this).addClass("delete");
    },function(){
    	$(this).removeClass("delete");
    });
 	// 初始化user列表
	initUserList('user_search_select');
	$(".user_search_select").selectpicker({
		width : 500
 	});
	$("#consumerSelect").selectpicker({
		width : 250
 	});
 	// search type tooltip
 	$("#searchCondition").selectpicker({
		width : 120
 	}).on('changed.bs.select', function(){
 	  	changeSearchType($('#searchCondition option:selected').val());
 	});
});
//准备删除
function prepareDeleteUserConsumer(uid,userName,consumerID){
	$("#user_name").val(userName);
	$("#currentUid").val(uid);
	$("#currentCid").val(consumerID);
	$("#deleteUserConsumerModal").modal('show');
}
//删除用户与消费者关联
function deleteUserConsumer(){
	disable("deleteUserConsumerBtn");
	$.post('${request.contextPath}/userConsumer/delete',
		{
			uid: $("#currentUid").val(),
			cid: $("#currentCid").val()
		},
        function(data){
            if(data.status == 200){
            	toastr.success("申请成功！请耐心等待！");  	            	
            	reload(1000);            	
		    }else{
		    	toastr.error("删除失败！"+data.message);  
		    	enable("deleteUserConsumerBtn");
		    }
    }, 'json');
}
/**
 * 初始化user下拉列表
 */
function initUserList(componentId){
	$.post('${request.contextPath}/user/list',
	        function(data){
	            if(data.status == 200){
	            	var content = "";
	            	for(var i in data.result){
	            		var user = data.result[i];
	            		var value = user.email.substring(0, user.email.indexOf("@"));
	            		if(user.name && user.name != value){
	            			value = user.name + "【" + value +"】";
	            		}
	            		content += "<option value='"+user.id+"'>"+value+"</option>";	
	            	}
	        		$("#"+componentId).html(content);
	        		$("#"+componentId).selectpicker('refresh');
			    }else{
			    	toastr.error("数据获取失败！"+data.message);  
			    }
        }, 'json');
}
//关联用户
function associateUserConsumer(consumerGroupID,consumerGroupName){
	$("#topicName").val('${topic.name}');
	$("#consumerGroupName").val(consumerGroupName);
	$("#consumerGroupID").val(consumerGroupID);
	$("#addUserConsumerModal").modal('show');
}
/**
 * 发送添加用户请求
 */
function addUserCounsumerRelationship(){
	if(!$("#user_search_select").val()){
		alert("请先选择用户");
		return;
	}
	disable("associateUserConsumerBtn");
	$.post('${request.contextPath}/consumer/auth/associate',
			{
				cid: $("#consumerGroupID").val(),
				tid: $("#tid").val(),
				uid: $('#user_search_select option:selected').val(),
			},
	        function(data){
	            if(data.status == 200){
	            	toastr.success("申请成功！请耐心等待！");  	            	
	            	reload(1000);            	
			    }else{
			    	toastr.error("申请失败！"+data.message);  
			    	enable("associateUserConsumerBtn");
			    }
	    }, 'json');
}

function hideMsgSearchModal(){
	$('#msgSearchModal').modal('hide');
}
//当前消息搜索时的topic
var currentSelectTopic = '';
var queueOffsetMap = null;
function brokerNameSelectChange(obj){
	var value = obj.options[obj.selectedIndex].value;
	if (value == "all"){
		$("#queueSearchSelect").html("<option value='-1'>全部</option>");
		$("#queueSearchSelect").selectpicker('refresh');
		$("#offsetStart").val(minAllOffset);
		$("#offsetEnd").val(maxAllOffset);
		return;
	}
	resetMaxOffsetByBrokerName(value);
	$.get('${request.contextPath}/consumer/broker/queue',
			{
				topic: currentSelectTopic,
				brokerName: value,
				clusterId : $("#toCid").val()
			},
	        function(data){
	            if(data.status == 200){
	            	queueOffsetMap = data.result;
	            	var content = "<option value='-1'>全部</option>";
	            	for (var  key in queueOffsetMap){
	            		content += "<option value='"+key+"'>"+key+"</option>";
	            	}
	            	$("#queueSearchSelect").html(content);
	            	$("#queueSearchSelect").selectpicker('refresh');
			    }
	    }, 'json');
}
var maxAllOffset = '';
var minAllOffset = '';
function initOffsetMsgModal(type, index, topic, maxOffset){
	// 清空数据
	$("#dataTable tbody").html("<tr class='no_more_data'><td colspan=5 class='text-center'>暂无数据</td></tr>");
	$("#dataTable input").remove();
	$("#toTopic").val(topic);
	$("#pager").hide();
	
	// 计算offset
	var start = maxOffset - 100;
	if(start < 0){
		start = 0;
	}
	maxAllOffset = maxOffset;
	minAllOffset = start;
	currentSelectTopic = topic;
	$("#offsetStart").val(start);
	$("#offsetEnd").val(maxOffset);
	$("#toKey").val("");
	
	if(type == "dlq") {
		$("#dataTable").addClass("tr-pointer");
		$("#resendMessageBtn").show();
		$("#cosumeTimes").html("消费次数");
	} else {
		$("#dataTable").removeClass("tr-pointer");
		$("#resendMessageBtn").hide();
		$("#cosumeTimes").html("重试次数");
	}
	//初始化broker列表
 	initBrokerList('brokerNameSearchSelect');
 	$("#queueSearchSelect").selectpicker('refresh');
}
//显示搜索条件broker和队列
function showMoreSearchCondition(){
	if ($("#moreSearchCondition").hasClass('hide')){
		$("#moreSearchCondition").removeClass('hide');
	} else {
		$("#moreSearchCondition").addClass('hide');
		//重置broker下拉框状态
		document.getElementById("brokerNameSearchSelect").options.selectedIndex = 0; //回到初始状态
	    $("#brokerNameSearchSelect").selectpicker('refresh');
	}
}
//偏移量消息搜索
function searchOffsetMessage(append){
	$("#toAppend").val(append);
	post('${request.contextPath}/topic/message/retry/search/offset', $("#msgSearchForm").serialize(), function(data){
		if(!append){
			$("#dataTable tbody").remove();
			$("#dataTable input").remove();
		}
       	$("#dataTable").append(data);
    });
}

var pageNum = 0;
//显示分页
function showPage(num){
	pageNum = num;
	var comp = $("#data_"+num);
	var size = comp.attr("data_size");
	var search = comp.attr("data_search");
	var left = comp.attr("data_left");
	$("#pageNum").html(num);
	$("#sizeNum").html(size);
	$("#searchNum").html(search);
	$("#leftNum").html(left);
	$("#pager").show();
	if(num == 1){
		$("#previous").addClass("disabled");
	} else {
		$("#previous").removeClass("disabled");
	}
	if(left > 0){
		$("#next").removeClass("disabled");
	} else {
		$("#next").addClass("disabled");
	}
	// 展示数据
	$("#page_"+pageNum).show().siblings("tbody").hide();
}
//上一页
function previous(){
	if(!$("#previous").hasClass("disabled")){
		showPage(pageNum - 1);
	}
}
//下一页
function next(){
	if(!$("#next").hasClass("disabled")){
		if($("#data_"+(pageNum+1)).length > 0){
			showPage(pageNum+1);
		} else {
			if($("#offsetStart").is(":visible")){
				searchOffsetMessage(true);
			} else {
				searchMessage(true);
			}
		}
	}
}
/**
 * 初始化broker下拉列表
 */
var brokerNameMap = null;
function initBrokerList(componentId){
	$.get('${request.contextPath}/topic/brokerName/list',
			{
				topic: currentSelectTopic,
				clusterId : $("#toCid").val()
			},
	        function(data){
	            if(data.status == 200){
	            	brokerNameMap = data.result;
	            	var content = "<option value='all'>全部</option>";
	            	for (var key in brokerNameMap){
	            		content += "<option value='"+key+"'>"+key+"</option>";
	            	}
	        		$("#"+componentId).html(content);
	        		$("#"+componentId).selectpicker('refresh');
			    }else{
			    	toastr.error("数据获取失败！"+data.message);  
			    }
        }, 'json');
}
function queueSelectChange(obj){
	var value = obj.options[obj.selectedIndex].value;
	var queue = parseInt(value);
	if (queue == -1){
		resetMaxOffsetByBrokerName($("#brokerNameSearchSelect").val());
		return;
	}
	resetMaxOffset(queue, 'queue');
}
//重置偏移量
function resetMaxOffsetByBrokerName(key){
	if (brokerNameMap != null){
		resetMaxOffset(key,'broker');
	}
}
function resetMaxOffset(key,type){
	var max = null;
	if (type == 'broker'){
		max = brokerNameMap[key];
	}else{
		max = queueOffsetMap[key];
	}
	
	var min = max - 100;
	if (min < 0){
		min = 0;
	}
	$("#offsetStart").val(min);
	$("#offsetEnd").val(max);
}

// 获取队列客户端ip
var queueOwnerInitArray = new Array();
function getQueueOwner(consumer, consumerId){
	if(queueOwnerInitArray[consumerId]){
		return;
	}
	$.get('${request.contextPath}/consumer/queue/owner',{
		cid: $("#toCid").val(),
		consumer: consumer
	},function(data){
        if(data.status == 200){
        	for(var i in data.result){
        		var id = "#" + data.result[i].topicType + "_" + consumerId + "_" + data.result[i].brokerName + "_" + data.result[i].queueId;
        		var prevContent = $(id).html();
        		if(prevContent){
        			prevContent += ","
        		}
	        	$(id).html(prevContent + data.result[i].clientId);
        	}
	    }else{
	    	toastr.error("获取客户端失败！"+data.message);  
	    }
        queueOwnerInitArray[consumerId] = true;
    }, 'json');
}

// 更新consumer用途
function updateConsumerInfo(){
	if(!$("#consumerInfo").val()){
		alert("请输入用途");
		return;
	}
	disable("updateConsumerInfoBtn");
	$.post('${request.contextPath}/consumer/update/info',
			{
				info: $("#consumerInfo").val(),
				cid: $("#currentConsumerID").val()
			},
	        function(data){
	            if(data.status == 200){
	            	toastr.success("操作成功！即将刷新页面！");  	            	
	            	reload(2000);            	
			    }else{
			    	toastr.error("操作失败！"+data.message);  
			    	enable("updateConsumerInfoBtn");
			    }
	    }, 'json');
}

//重发消息 提示
function resendMessageTip(){
	var dataIdxArray = new Array();
	$('#dataTable tbody tr.selected').each(function(){
		dataIdxArray.push($(this).attr("dataIdx"));
	});
	if(dataIdxArray.length == 0) {
		alert("请先选择消息(支持shift和ctrl)");
		return;
	}
	$("#dataIdx").html(dataIdxArray.toString());
	// 获取消费者
	$.get('${request.contextPath}/userConsumer/list',
		{
			tid: ${RequestParameters.tid}
		},
        function(data){
            if(data.status == 200){
            	if(data.result.length == 0) {
	        		$("#consumerSelect").html("<option value='-1'>无关联的消费者</option>");
	        		$("#consumerSelect").selectpicker('val', "-1");
	        		$("#resendBtn").attr("disabled", "disabled");
        		} else {
	            	var content = "";
	            	for(var i in data.result){
	            		var consumer = data.result[i];
	            		content += "<option value='"+consumer.id+"'>"+consumer.name+"</option>";
	            	}
	        		$("#consumerSelect").html(content);
	        		$("#consumerSelect").selectpicker('refresh');
	        		if(data.result.length == 1){
		        		$("#consumerSelect").selectpicker('val', data.result[0].id);
	        		}
        		}
				$('#resendMsgModal').modal('show');
		    }else{
		    	toastr.error("错误！"+data.message);  
		    }
    }, 'json');
}

//重发消息 
function resendMessage(){
	var dataArray = new Array();
	$('#dataTable tbody tr.selected').each(function(){
		dataArray.push($(this).attr("data"));
	});
	if(dataArray.length == 0) {
		alert("请先选择消息(支持shift和ctrl)");
		return;
	}
	if($("#consumerSelect").val().length == 0){
		alert("请选择消费者");
		return;
	}
	disable("resendBtn");
	$.post('${request.contextPath}/topic/message/resend',
		{
			msgIds: dataArray.toString(),
			tid: ${RequestParameters.tid},
			cid: $("#consumerSelect").val()
		},
        function(data){
			enable("resendBtn");
            if(data.status == 200){
            	toastr.success("申请成功！请耐心等待！");  	            	
            	$('#resendMsgModal').modal('hide');       	
		    }else{
		    	toastr.error("申请失败！"+data.message);  
		    }
    }, 'json');
}

function updateConsumerTraceShow(cid, consumer, traceable){
	$("#consumerH4").val(cid);
	$("#consumerH4").html(consumer);
	if(traceable == 1) {
		$("#traceSapn").html("关闭");
		$("#traceSapn").val(0);
	} else {
		$("#traceSapn").html("开启");
		$("#traceSapn").val(1);
	}
	$('#updateConsumerTraceModal').modal('show');
}
function updateConsumerTrace(){
	disable("updateConsumerTraceBtn");
	$.post('${request.contextPath}/consumer/update/trace',
			{
				cid: $("#consumerH4").val(),
				traceEnabled: $("#traceSapn").val()
			},
	        function(data){
	            if(data.status == 200){
	            	toastr.success("修改成功！请重启应用！");  	            	
	            	reload(2000);            	
			    }else{
			    	toastr.error("操作失败！"+data.message);  
			    	enable("updateConsumerTraceBtn");
			    }
	    }, 'json');
}
<#if response.OK>
	$(function() {
		lineChart("consume", function (){
			$("#tid").val("${RequestParameters.tid}");
			<#if RequestParameters.consumer??>
				$("#_consumer").val("${RequestParameters.consumer}");
			</#if>
			<#if RequestParameters.currentPage??>
				$("#currentPage").val(${RequestParameters.currentPage});
			</#if>
		});
		<#if RequestParameters.consumer?? && RequestParameters.consumer != "">
			$('a[data="${RequestParameters.consumer}"]').click();
		</#if>
	});
</#if>

// 更改搜素选项
var prevSearchType = "key";
function changeSearchType(type){
	// 无改变
	if(prevSearchType == type){
		return;
	}
	$("."+type).show();
	if(prevSearchType) {
		$("."+prevSearchType).hide();
	}
	prevSearchType = type;
	
	$("#pager").hide();
	hideAndResetBrokerSelect();
	// 清空数据
	$("#dataTable tbody").remove();
	$("#dataTable").append("<tbody><tr class='no_more_data'><td colspan=5 class='text-center'>暂无数据</td></tr></tbody>");
	$("#dataTable input").remove();
	$("#dataTable").removeClass("hide");
	$("#resendMessageBtn").removeClass("disabled");
}

function hideAndResetBrokerSelect(){
	$("#moreSearchCondition").addClass('hide');
	//重置broker下拉框状态
    $("#brokerNameSearchSelect").selectpicker('val', "all");
    $("#queueSearchSelect").selectpicker('val', "-1");
}

//消息搜索
function searchMessage(append){
	$("#toAppend").val(append);
	post('${request.contextPath}/topic/message/retry/search/time', $("#msgSearchForm").serialize(), function(data){
		if(!append){
			$("#dataTable tbody").remove();
			$("#dataTable input").remove();
		}
       	$("#dataTable").append(data);
    });
}
//消息key搜索
function searchKeyMessage() {
	if(!$("#msgKey").val()){
		alert("消息key不能为空");
		return;
	}
	post('${request.contextPath}/topic/message/retry/search/key', $("#msgSearchForm").serialize(), function(data){
		$("#dataTable tbody").remove();
		$("#dataTable input").remove();
       	$("#dataTable").append(data);
    });
}

function timeChange(id){
	var dt = $("#" + id + "Picker").val();
	var tm = parseDate(dt);
	$("#" + id).val(tm);
}
//初始化key查询方式的时间
timeChange('keyStartTime');
</script>